package com.shen.springcloud.controller;

import com.shen.apicommons.entity.Student;
import com.shen.apicommons.util.CommentUtil;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@Slf4j
public class OrderController {

    public static final String PRYMENT_URL="http://cloud-provider-service";
    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/consumer/sc/addStudent")
    public CommentUtil<Student> create(Student student){
        return restTemplate.postForObject(PRYMENT_URL+"/sc/addStudent",student,CommentUtil.class);
    }
    @GetMapping("/consumer/sc/selectStudent/get/{id}")
    public CommentUtil<Student> getStudent(@PathVariable("id") Integer id){
        return restTemplate.getForObject(PRYMENT_URL+"/sc/selectStudent/get/"+id,CommentUtil.class);
    }
}
